import axios from '@/http/index'

export function getUsers(currentPage = 1, take = 10, filter = '') {
  return axios({
    url: '/api/identity/users',
    method: 'get',
    params: {
      skipCount: take * (currentPage - 1),
      maxResultCount: take,
      filter
    }
  })
}

// 新增用户
export function addUser(data) {
  return axios({
    url: '/api/identity/users',
    method: 'post',
    data
  })
}

// 查询用户权限
export function getUserPermission(id) {
  return axios({
    url: `/api/identity/users/${id}/roles`,
    method: 'get'
  })
}

// 删除用户
export function deleteUser(id) {
  return axios({
    url: `/api/identity/users/${id}`,
    method: 'delete'
  })
}

// 查询可以使用的角色
export function assignableRoles() {
  return axios({
    url: `/api/identity/users/assignable-roles`,
    method: 'get'
  })
}

// 修改角色
export function updateUser(id, data) {
  return axios({
    url: `/api/identity/users/${id}`,
    method: 'put',
    data
  })
}

// 获取用户列表（全部用户）
export function getUserList(name) {
  return axios({
    method: 'get',
    url: `/api/user/list`,
    params: { name: name }
  })
}

// 获取标注用户列表
export function getMarkUserList(name) {
  return axios({
    method: 'get',
    url: `/api/identity/user/list`,
    params: { name: name }
  })
}
